package com.wpf.test01;

import java.util.Scanner;

public class demo03 {
    public static void main(String[] args) {
        while (true) {
            try {
                System.out.println(price());
                break;
            } catch (Exception e) {
                System.out.println("请输入合法的数字！！！！！");
            }
        }
    }

    public static double price(){
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入合适的价格(1-100之间)：");
            double p1 = sc.nextDouble();
            if(p1 >=1 && p1 <= 100){
                return p1;
            }else{
                System.out.println("价格不合适，请重新输入");
            }
        }
    }
}
